module.exports = function($scope, $state, $stateParams,$resource,$modal){
 console.log('shenbie');
	var para = {};
	var view = $stateParams.placecode;
	if(view !== '') para['view'] = view;

	function load(){
		$resource('/api/as/tc/device/watchdevicelist', {}, {}).
		get(para, function(res){

			console.log(res);
			if(res.errcode === 0)
			{
				$scope.objs = res.data;
			}
			else
			{
				alert(res.errmsg);
			}

		});
	}
	load();


	//打开模态框
	$scope.configurationticket = function(device_code, place_code){
		console.log('配置票种');
		var modalInstance = $modal.open({
        template: require('../views/tickettypelist.html'),
        controller: 'tickettypelist',
        size: 'lg',
        resolve: {
            view : function(){
	      		return place_code;
	      	},
	      	device_code : function(){
	      		return device_code;
	      	},
         }
        });
        modalInstance.result.then(function (showResult) {	
            $scope.load();
        });
		
	}

	$scope.edit = function(id){
		// console.log('111');
		$state.go('app.skdevicetktedit', {'id' : id,});

	};

	$scope.create = function()
	{	
		console.log(view);
		// $state.go('app.skdevicetktcreate', {'placecode' : view});
		// $state.go('app.skdevicetktedit', {'id' : id,});
		$state.go('app.skdevicetktedit', {'placecode' : view});
		
	};


};